package com.central.post.controller

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.central.common.annotation.LoginUser
import com.central.common.model.CommonResult
import com.central.common.model.PageVo
import com.central.common.model.SysUser
import com.central.post.pojo.authenticate.*
import com.central.post.service.AuthenticateService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*
import springfox.documentation.annotations.ApiIgnore

/**
 * @author  fly
 * @date  2021/5/26 14:55
 * @version 1.0
 */
@Api(tags = ["(小程序) 山正鉴定模块"])
@RestController
@RequestMapping("authenticate")
open class AuthenticateController {

    @Autowired
    private lateinit var authenticateService: AuthenticateService


    @ApiOperation("发布山正鉴定帖子")
    @PostMapping("/publishAuthenticate")
    fun publishAuthenticate(authenticatePublishDto: AuthenticatePublishDto, @ApiIgnore @LoginUser sysUser: SysUser): CommonResult<Boolean> =
        authenticateService.publishAuthenticate(authenticatePublishDto, sysUser)

    @ApiOperation("移除山正鉴定帖子")
    @DeleteMapping("/removeAuthenticate")
    fun removeAuthenticate(ids: String): CommonResult<Boolean> =
        authenticateService.removeAuthenticate(ids)

    @ApiOperation("山正鉴定首页数据")
    @GetMapping("/getAuthenticateIndexData")
    fun getAuthenticateIndexData(): CommonResult<AuthenticateIndexData> =
        authenticateService.getAuthenticateIndexData()

    @ApiOperation("山正鉴定详情数据")
    @GetMapping("/getAuthenticateDetail")
    fun getAuthenticateDetail(id: Long, @ApiIgnore @LoginUser sysUser: SysUser, pageVo: PageVo): CommonResult<AuthenticateDetailVo> =
        authenticateService.getAuthenticateDetail(id, sysUser, pageVo)

    @ApiOperation("鉴定达人")
    @GetMapping("/getAuthenticateTalentList")
    fun getAuthenticateTalentList(authenticateSearchDto: AuthenticateSearchDto, pageVo: PageVo): CommonResult<Page<AuthenticateTalentList>> =
        authenticateService.getAuthenticateTalentList(authenticateSearchDto, pageVo)

    @ApiOperation("山正鉴定搜索结果")
    @GetMapping("/searchAuthenticateList")
    fun searchAuthenticateList(authenticateSearchDto: AuthenticateSearchDto, pageVo: PageVo): CommonResult<Page<AuthenticateSearchListVo>> =
        authenticateService.searchAuthenticateList(authenticateSearchDto, pageVo)

    @ApiOperation("我的鉴定记录")
    @GetMapping("/getMyPublishAuthenticate")
    fun getMyPublishAuthenticate(pageVo: PageVo, @ApiIgnore @LoginUser sysUser: SysUser): CommonResult<Page<AuthenticateListVo>> =
        authenticateService.getMyPublishAuthenticate(pageVo, sysUser)

    @ApiOperation("鉴定山正")
    @PostMapping("/authenticate")
    fun authenticate(authenticateDto: AuthenticateDto, @ApiIgnore @LoginUser sysUser: SysUser): CommonResult<Boolean> =
        authenticateService.authenticate(authenticateDto, sysUser)

}
